package manager
{
	import flash.utils.Dictionary;
	
	import loaderData.LoaderSys;

	public class XmlMgr
	{
		
		private static var instance:XmlMgr;
		
		public var xmlList:Dictionary = new Dictionary(true);

		public var strPath:String = "../data/xml/";
		public function XmlMgr()
		{
		}
		
		public static function get inst():XmlMgr
		{
			return instance ||= new XmlMgr();
		}

		/**
		 * 获取原始ＸＭＬ数据 
		 * @param str
		 * @return 
		 * 
		 */		
		public function getXML(str:String):XML
		{
			str = strPath + str;
			
			var xml:XML = LoaderSys.inst.getXML(str) as XML;
			return xml;
		}
		
		/**
		 *　获取ＸＭＬ类 
		 * @param cl
		 * @return 
		 * 
		 */		
		public function GetXMLData(cl:Class):*
		{
			if(xmlList[cl])
				return xmlList[cl];
			
			var item:* = new cl();
			
			xmlList[cl] = item;
			
			return item;
		}
		
		
		/**
		 * 预先需要加载的xml资源
		 * @return 
		 * 
		 */		
		public function getXmlList():Array
		{
			var xml:XML = getXML("xmlList.xml");

			var xmllist:XMLList = xml.children();
			
			var arr:Array = new Array();
			
			for (var i:int = 0; i < xmllist.length(); i++) 
			{
				arr.push(strPath + xmllist[i].@url);
			}
			return arr;
		}
		
		
	}
}